package com.louis.iread.utils;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created by louis on 17-11-9.
 */

public class ThreadPool {
    private ExecutorService mCachedThreadPool = null;

    private static ThreadPool mThreadPool = null;

    private ThreadPool() {
        mCachedThreadPool = Executors.newCachedThreadPool();
    }

    public void closePool() {
        mCachedThreadPool.shutdown();
    }

    public static ThreadPool getInstance() {
        if (mThreadPool == null) {
            mThreadPool = new ThreadPool();
        }
        return mThreadPool;
    }

    public void commit(Runnable task) {
        mCachedThreadPool.execute(task);
    }
}
